package ua.pp.bizon.yandex.api;

import ua.pp.bizon.yandex.api.impl.Element;

import java.util.List;

import javax.management.Notification;
import javax.management.NotificationListener;

public interface IJobExecutor extends NotificationListener {

	/**
	 * create new job by the Element and execute it in "Job Executor" thread
	 * 
	 * @param element
	 */
	public abstract void exec(final Element element);

	/**
	 * execute job in "Job Executor" thread
	 * 
	 * @param job
	 */
	public abstract void exec(Job job);

	/**
	 * execute job in swing thread; no wait job
	 * 
	 * @param job
	 */
	public abstract void execInSwing(Job job);

	/**
	 * execute job in swing thread; if wait = true then wait
	 * 
	 * @param job
	 */
	public abstract void execInSwing(Job job, boolean wait);

	/**
	 * 
	 * @return list of Elements with info about jobs in stack
	 */
	public abstract List<Element> getStateInfo();

	/**
	 * if notification.getSource() instance of Element - add element as job
	 */
	public abstract void handleNotification(Notification notification, Object handback);

	/**
	 * 
	 * @return listener to handle notifications
	 */
	public abstract NotificationListener listener();

}